package com.Adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.Welcome.R;

public class GridView2Adapter extends BaseAdapter {
	private List<Map<String, Object>> list = null;
	private LayoutInflater inflater = null;

	public GridView2Adapter(Context context, List<Map<String, Object>> list) {
		this.list = list;
		this.inflater = LayoutInflater.from(context);

	}

	@Override
	public int getCount() {
		return this.list != null ? this.list.size() : 0;
	}

	@Override
	public Object getItem(int position) {
		return this.list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewTempholder holder;
		if (null == convertView) {
			convertView = inflater.inflate(R.layout.gridviewitem, null);
			holder = new ViewTempholder();
			holder.num = (TextView) convertView.findViewById(R.id.GridNum);
			holder.info = (TextView) convertView.findViewById(R.id.GridText);
//			holder.OptionsButton = (Button) convertView
//					.findViewById(R.id.OptionsButton);
			convertView.setTag(holder);
		} else {
			holder = (ViewTempholder) convertView.getTag();
		}
		holder.num.setText(list.get(position).get("Num").toString());
		holder.info.setText(list.get(position).get("Text").toString());
//		holder.OptionsButton.setText(list.get(position).get("Num").toString());
		return convertView;
	}

	private static class ViewTempholder {

		TextView num;
		TextView info;
		Button OptionsButton;

	}

}
